#include "Vofa.h"

/* value of VOFA+ JustFloat*/
const uint8_t tail [4] = {0x00, 0x00, 0x80, 0x7f};	//结束数组
uint8_t c_data[4];	//存放转化后的数组


//f:输入数据 c:存储数据数组
void float_turn_u8(float f,uint8_t * c)
{
	uint8_t x;
	FloatLongType data;
	data.fdata=f;
	
	for(x=0;x<4;x++)
	{
		c[x]=(uint8_t)(data.ldata>>(x*8));
	}
}

//fdata:float数据数组 fdata_num:float数组数据个数/通道个数 Usart_choose选择发送的串口 如：USART1
void JustFloat_Send(float * fdata,uint16_t fdata_num, UART_Regs *Usart_choose)
{
	uint16_t x;
	uint8_t y;
		for(x=0;x<fdata_num;x++)
		{
			float_turn_u8(fdata[x],c_data);
			for(y=0;y<4;y++)
			{
				while (DL_UART_isBusy(Usart_choose) == true);
				DL_UART_Main_transmitData(Usart_choose, c_data[y]);
			}
		}
		for(y=0;y<4;y++)
		{
			while (DL_UART_isBusy(Usart_choose) == true);
			DL_UART_Main_transmitData(Usart_choose, tail[y]);
		}
}
